package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.HotelTheme;
import cn.wolfcode.luowowo.article.mapper.HotelThemeMapper;
import cn.wolfcode.luowowo.article.query.HotelThemeQuery;
import cn.wolfcode.luowowo.article.service.IHotelThemeService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class HotelThemeServiceImpl implements IHotelThemeService {
    @Autowired
    private HotelThemeMapper hotelThemeMapper;

    @Override
    public PageInfo query(HotelThemeQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        return new PageInfo(hotelThemeMapper.selectForList(qo));
    }

    @Override
    public void saveOrUpdate(HotelTheme hotelTheme) {
        if(hotelTheme.getId() == null){
            hotelThemeMapper.insert(hotelTheme);
        }else{
            hotelThemeMapper.updateByPrimaryKey(hotelTheme);
        }
    }

    @Override
    public List<HotelTheme> list() {
        return hotelThemeMapper.selectAll();
    }
}
